<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/pages/common/header.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Third Challan</title>
<script>
	function amountCalculation(count) {
		var billQuantity = document.getElementById("billQuantity").innerHTML;
		var ratePerMT = document.getElementById("ratePerMT").value;
		var invoiceAmt = ratePerMT * billQuantity;
		var roundOffinvoiceAmt = Math.round(invoiceAmt * 100) / 100
		
		document.getElementById("invoiceAmount").innerHTML = roundOffinvoiceAmt;
		document.getElementById("repeatedDisplay").innerHTML = roundOffinvoiceAmt;

		var into3Amt = document.getElementById("into3Amt").innerHTML;

		var sum = parseFloat(into3Amt) + parseFloat(invoiceAmt);
		sum = Math.round(sum);

		document.getElementById("grandAmount").innerHTML = sum;
		document.getElementById("repeatedgrandAmount").innerHTML = sum;

		var stringValue = convert_number(sum);
		document.getElementById("grandAmountInWord").innerHTML = stringValue;
	}

	function mtCalculation() {
		var mt = document.getElementById("mt").innerHTML;
		var userInputInRs = document.getElementById("userInputInRs").value;

		var amtInRs = mt * userInputInRs;
		var roundOffAmt = Math.round(amtInRs * 100) / 100
		document.getElementById("amtInRs").innerHTML = roundOffAmt;

		var into3Amt = 3 * amtInRs;
		var roundOffinto3Amt = Math.round(into3Amt * 100) / 100
		document.getElementById("into3Amt").innerHTML = roundOffinto3Amt;

		var invoiceAmount = document.getElementById("invoiceAmount").innerHTML
		var sum = into3Amt + parseFloat(invoiceAmount);
		sum = Math.round(sum);
		document.getElementById("grandAmount").innerHTML = sum;
		document.getElementById("repeatedgrandAmount").innerHTML = sum;

		var stringValue = convert_number(sum);
		document.getElementById("grandAmountInWord").innerHTML = stringValue;
	}
	
	function saveForm(){
		var amt = document.getElementById("grandAmount").innerHTML;
		document.getElementById("grandTotal").value = amt;
		var form = document.getElementById("finalChallan");
		form.submit();
		
	}
	function onloadCalculation(mulFactor,ratePerMT,mtValue){
		
		var billQuantity = document.getElementById("billQuantity").innerHTML;
		/* var ratePerMT = document.getElementById("ratePerMT").innerHTML; */
		
		var invoiceAmt = ratePerMT * billQuantity;
		var roundOffinvoiceAmt = Math.round(invoiceAmt * 100) / 100
		
		document.getElementById("invoiceAmount").innerHTML = roundOffinvoiceAmt;
		document.getElementById("repeatedDisplay").innerHTML = roundOffinvoiceAmt;
		
		var mt = document.getElementById("mt").innerHTML;
		var userInputInRs = mtValue;

		var amtInRs = mt * userInputInRs;
		var roundOffAmt = Math.round(amtInRs * 100) / 100;
		document.getElementById("amtInRs").innerHTML = roundOffAmt;

		var into3Amt = parseInt(mulFactor) * amtInRs;
		var roundOffinto3Amt = Math.round(into3Amt * 100) / 100;
		document.getElementById("into3Amt").innerHTML = roundOffinto3Amt;

		var invoiceAmount = document.getElementById("invoiceAmount").innerHTML
		var sum = parseFloat(invoiceAmount)-into3Amt;
		sum = Math.round(sum);
		document.getElementById("grandAmount").innerHTML = sum;
		document.getElementById("repeatedgrandAmount").innerHTML = sum;

		var stringValue = convert_number(sum);
		document.getElementById("grandAmountInWord").innerHTML = stringValue;

	}
</script>
</head>
<c:set var="traderObj" value="${requestScope.traderObj}" />
	<c:set var="grossWeightTotal" value="${requestScope.grossWeightTotal}" />
	<c:set var="netWeightTotal" value="${requestScope.netWeightTotal}" />
	<c:set var="finalDifference" value="${requestScope.finalDifference}" />
	<c:set var="ids" value="${requestScope.ids}" />
	<c:forEach var="traders" items="${traderObj}" varStatus="counter">
		<c:set var="traderId" value="${traders.companyId}" />
		<c:set var="traderName" value="${traders.companyName}" />
		<c:set var="address" value="${traders.address}" />
			
			<c:set var="contactNo" value="${traders.contactNo}" />
		<c:set var="mobileNo" value="${traders.mobileNo}" />
		<c:set var="panNo" value="${traders.panNo}" />
		<c:set var="bankName" value="${traders.bankName}" />
		<c:set var="accountNo" value="${traders.accountNo}" />
		<c:set var="ifscCode" value="${traders.ifscCode}" />
		<c:set var="micrCode" value="${traders.micrCode}" />
		<c:set var="extraField1" value="${traders.extraField1}" />
		<c:set var="mulFactor" value="${traders.mulFactor}"></c:set>
		<c:set var="ratePerMT" value="${traders.landingCost}"></c:set>
	</c:forEach>
	
	<c:set var="datefrmFirstChallan" value="${requestScope.dateInString}" />
	<c:set var="raBillNo" value="${requestScope.raBillNo}" />
	
	<c:set var="transDispatchFrom" value="${requestScope.transDispatchFrom}" />
	<c:set var="transDispatchTo" value="${requestScope.transDispatchTo}" />
	
	<c:set var="companyInfo" value="${requestScope.companyInfo}"/>
		<c:forEach var="cd" items="${companyInfo}" varStatus="counter">
			<c:set var="upCompanyId" value="${cd.companyId}"></c:set>
			<c:set var="upCompanyName" value="${cd.companyName}"></c:set>
			<c:set var="upAddress" value="${cd.address}"></c:set>
		</c:forEach>
		

<body class="mainbody" onload="onloadCalculation('${mulFactor}','${ratePerMT}','${extraField1}')">
	
	<div class="mainContainer">
		<section class="bodyContainer">
		<div class="challan3Report">
			<div class="billPageDiv">
				<div class="billHeader">
					<div class="transcontDetaisBill">
						<h1 class="transcNameHding">${traderName}</h1>
						<h3 class="transHdingadrssDtls">
							<strong>Pan No. :</strong> ${panNo} (Name : ${traderName})
						</h3>
						<h3 class="transHdingadrssDtls">${address}</h3>
						<h3 class="transHdingadrssDtls">
							<strong>Phone No. :</strong> ${contactNo}
							&nbsp;&nbsp;&nbsp;&nbsp; <strong>Mobile No. :</strong>
							${mobileNo}
						</h3>
					</div>
				</div>
				<p class="hrlineBr"></p>
				<div class="billContDesc">
					<div class="divclear">
						<div class="contPersonalDtls">
							<p class="spacerTopTen"></p>
							<h3 class="adrssDtls">
								<span class="billLableTxt">To</span>
							</h3>
							<h3 class="adrssDtls">
								<span class="billTxt">${upCompanyName}
								
								</span>
							</h3>
							<h3 class="adrssDtls">
								<span class="billTxt">${upAddress}</span>
							</h3>

						</div>

						<div class="transcontBillDtls">
							<h3 class="adrssDtls">
								<span class="transBillLableTxtLft">Bill No :</span><span
									class="transBillLableTxtRght"><strong><input type="text"
									value="${raBillNo}" name="${raBillNo}" class="transbillLable"></strong>
								</span>
							</h3>
							<h3 class="adrssDtls">
								<span class="transBillLableTxtLft">Bill Date :</span><span
									class="transBillLableTxtRght"><strong> <input type="text"
									value="${datefrmFirstChallan}"  class="transbillLable"></strong>
								</span>
							</h3>
							<h3 class="adrssDtls">
								<span class="transBillLableTxtLft">PCP Ref.No :</span><span
									class="transBillLableTxtRght"><strong><input type="text"
									value=""  class="transbillLable"></strong>
								</span>
							</h3>
							<h3 class="adrssDtls">
								<span class="transBillForTranLableTxtLft">Transportation
									Dispatch Period From :</span> <span class="transBillLableTxtRght"><input type="text"
									value="${transDispatchFrom}"  name="transDispatchFrom" class="transbillLable"></span>
							</h3>
							<h3 class="adrssDtls">
								<span class="transBillForTranLableTxtLft">To :</span><span
									class="transBillLableTxtRght"><input type="text"
									value="${transDispatchTo}"  name="transDispatchTo" class="transbillLable"> </span>
							</h3>
							<h3 class="adrssDtls">
								<span class="transBillForTranLableTxtLft">Transportation
									Dispatch From :</span><span class="transBillLableTxtRght"><strong>Valia
									Lignite Mines</strong></span>
							</h3>
							<h3 class="adrssDtls">
								<span class="transBillForTranLableTxtLft">To :</span><span
									class="transBillLableTxtRght"><strong>Vastan Power Plant Area</strong></span>
							</h3>

						</div>
					</div>
					<p class="spacerTopTen"></p>
					<div class="divclear">
						<h3 class="transMiddleHding">PCP Ref No. : - LOI No. -
							SLPP/ Mines / Valia Mine / 12-13 / 6985. 17/09/2012.</h3>
					</div>
					<div class="divclear">
						<h3 class="transportationBillHeading">LIGNITE TRANSPORTATION
							BILL</h3>
					</div>

					<p class="spacerTopTen"></p>
					<div class="divclear">
						<table width="950px" border="0" cellspacing="0" cellpadding="2"
							class="transbillReportTable">
							<tr>
								<th width="3%">Sr. No.</th>
								<th colspan="2">Particulars</th>
								<th width="12%">This Bill Qty. <br>M.T</th>
								<th width="15%">Rate Per M.T.<br> In Rupees Rs.</th>
								<th width="17%">Amount of Invoice<br> in
									Rupees(Rounded / Paisa)</th>
							</tr>
							<tr>
								<td>1</td>
								<td colspan="2">Lignite Transportation ( -250 mm Size )
									From Valia Lignite Mines To Vastan Power Plant Area. As Per
									Daily Dispatch Statement and Weigh Bridge Report Slip Attach
									Here with.</td>
								<td id="billQuantity">${netWeightTotal}</td>
								<td id="ratePerMT">${ratePerMT}<!-- <input type="text" value="0.0" id="ratePerMT"
									class="challanLable" onkeyup="amountCalculation()"> -->
								</td>
								<td id="invoiceAmount">0.0</td>

							</tr>
							<tr>
								<td>2</td>
								<td colspan="4">Total Transporatation Freight Amount Before
									Deduction Transit Loss if any</td>
								<td id="repeatedDisplay">0.0</td>
							</tr>
							<tr>
								<td rowspan="2">3</td>
								<td width="40%" rowspan="2">LESS : RECOVERY OF TRANSIT LOSS
									QUANTITY ( And Multiply by ${mulFactor} * Lignite landing cost) As Per
									Attachment</td>
								<td width="13%"><strong>M.T</strong>
								</td>
								<td><strong>Rs.</strong>
								</td>
								<td><strong>Amount Rs.</strong>
								</td>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<td id="mt"><fmt:formatNumber pattern="0.000"
										value="${finalDifference}" />
								</td>
								<td>${extraField1}<!-- <input type="text" value="0.0" id="userInputInRs"
									class="challanLable" onkeyup="mtCalculation()"> -->
								</td>
								<td id="amtInRs">0.0</td>
								<td id="into3Amt">0.0</td>
							</tr>
							<tr>
								<td>4</td>
								<td colspan="4">Net Transporatation Freight Claim Amount
									After Less Transit Loss</td>
								<td id="repeatedgrandAmount">0</td>
							</tr>
							<tr>
								<td></td>
								<td colspan="3"></td>
								<td><strong>Rs.</strong>
								</td>
								<td><strong id="grandAmount">0</strong>
								</td>
							</tr>
							<tr>
								<td></td>
								<td><strong>Rupees In Word :</strong></td>
								<td colspan="4" align="left"><strong id="grandAmountInWord">Amount
										In Word</strong>
								</td>
							</tr>
						</table>

					</div>

					<p class="spacerTopTen"></p>

					<div class="divclear">
						<div class="transsignatureDiv">
							<div class="divclear">for, ${traderName}</div>
							<p class="spacerTopTen"></p>
							<p class="spacerTopTen"></p>
							<p class="spacerTopTen"></p>
							<p class="spacerTopTen"></p>
							<p class="spacerTopTen"></p>
							<p class="spacerTopTen"></p>
							<p class="spacerTopTen"></p>
							<div class="divclear" style="border-top: 1px solid #999;">Signatory
								& Stamp</div>
						</div>
						<p class="spacerTopTen"></p>
						<div id="buttonShow">
							<div id="buttonsHide" class="divclear">
								<span class="buttonSiyora button80" onclick="saveForm();"><a> Save</a>
								</span> <span class="buttonSiyora button80"
									onclick="printSecondChallan();AfterThirdPrint();"><a>
										Print</a>
								</span>
								<span class="buttonSiyora button80"><a href="${context}/pages/jsp/welcome.jsp" >Home </a> </span>
							</div>
						</div>
						<p class="spacerTopTen"></p>
					</div>

					<div class="divclear">
						<div class="transdeclarationDiv">
							<h3 class="transadrssDtls">
								<strong># Note : </strong>
							</h3>
							<h3 class="transadrssDtls">1) Please Cheque Issue Name
								Should Be : " ${traderName}"</h3>
							<h3 class="transadrssDtls">2) My Bank Account Details is
								${bankName}. Acc No. : <input type="text" value="${accountNo}" class="transbillLable"></h3>
							<h3 class="transadrssDtls">2) My Bank IFS Code : <input type="text" value="${ifscCode}" class="transbillLable">
								MICR Code : <input type="text" value="${micrCode}" class="transbillLable"></h3>
						</div>
					</div>
				</div>
			</div>
		</div>
		</section>
	</div>
	<form id="finalChallan" action="${context}/challan3" method="post">
		<input type="hidden" name="billedIds" value="${requestScope.recordIds}" /> 
		<input type="hidden" name="traderId" value="${traderId}" /> 
		<input type="hidden" name="finalDifference" value="${finalDifference}"/>
		<input type="hidden" name="grossWeightTotal" value="${grossWeightTotal}"/>
		<input type="hidden" name="netWeightTotal" value="${netWeightTotal}"/>
		<input type="hidden" name="grandTotal" id="grandTotal"/>
		<input type="hidden" name="slipIds" value="${requestScope.challanIds}"/>
		<input type="hidden" name="ACTION" value="THRCS"/>
	</form>
	<!--main container-->
	<p class="spacerTopTen"></p>
	<p class="spacerTopTen"></p>
</body>
</html>
